import axios from 'axios'

/**
 * 获取楼宇列表
 * @param {*} params 
 * @returns 
 */
export function getBuildingList(params) {
    return axios.get('/api/assets/buildings', {
        params
    });
}

/**
 * 获取楼宇详情
 * @param {*} id 
 * @returns 
 */
export function getBuildingDetail(id) {
    return axios.get(`/api/assets/buildings/${id}/`);
}

/**
 * 获取楼宇的楼层列表
 * @param {*} id 
 * @returns 
 */
export function getBuildingFloors(id) {
    return axios.get(`/api/assets/buildings/${id}/floors/`);
}

/**
 * 获取楼宇的设备列表
 * @param {*} id 
 * @returns 
 */
export function getBuildingDevices(id) {
    return axios.get(`/api/assets/buildings/${id}/devices/`);
}

/**
 * 获取楼层详情
 * @param {*} id 
 * @returns 
 */
export function getFloorDetail(id) {
    return axios.get(`/api/assets/floors/${id}/`);
}

/**
 * 获取楼层的房间列表
 * @param {*} id 
 * @returns 
 */
export function getFloorRooms(id) {
    return axios.get(`/api/assets/floors/${id}/rooms/`);
}

/**
 * 获取楼层的公共设备列表
 * @param {*} id 
 * @returns 
 */
export function getFloorPublicDevices(id) {
    return axios.get(`/api/assets/floors/${id}/public_devices/`);
}

/**
 * 获取单元/房间详情
 * @param {*} id 
 * @returns 
 */
export function getUnitDetail(id) {
    return axios.get(`/api/assets/units/${id}/`);
}

/**
 * 获取单元/房间的设备列表
 * @param {*} id 
 * @returns 
 */
export function getUnitDevices(id) {
    return axios.get(`/api/assets/units/${id}/devices/`);
}

/**
 * 获取房间的设备列表（别名，与getUnitDevices功能相同）
 * @param {*} id 
 * @returns 
 */
export function getRoomDevices(id) {
    return axios.get(`/api/assets/units/${id}/devices/`);
}

/**
 * 更新楼层信息
 * @param {*} id 
 * @param {*} data 
 * @returns 
 */
export function updateFloor(id, data) {
    return axios.put(`/api/assets/floors/${id}/`, data);
}

/**
 * 获取房间详情
 * @param {*} id 
 * @returns 
 */
export function getRoomDetail(id) {
    return axios.get(`/api/assets/units/${id}/`);
}

/**
 * 获取房间的合同信息
 * @param {*} id 
 * @returns 
 */
export function getRoomContract(id) {
    return axios.get(`/api/assets/units/${id}/contract/`);
}

/**
 * 获取设备列表
 * @param {*} params 
 * @returns 
 */
export function getDeviceList(params) {
    return axios.get('/api/assets/devices/', { params });
}

/**
 * 获取设备详情
 * @param {*} id 
 * @returns 
 */
export function getDeviceDetail(id) {
    return axios.get(`/api/assets/devices/${id}/`);
}

/**
 * 添加设备
 * @param {*} data 
 * @returns 
 */
export function addDevice(data) {
    return axios.post('/api/assets/devices/', data);
}

/**
 * 更新设备
 * @param {*} id 
 * @param {*} data 
 * @returns 
 */
export function updateDevice(id, data) {
    return axios.put(`/api/assets/devices/${id}/`, data);
}

/**
 * 删除设备
 * @param {*} id 
 * @returns 
 */
export function deleteDevice(id) {
    return axios.delete(`/api/assets/devices/${id}/`);
}

/**
 * 获取车辆列表
 * @param {*} params 
 * @returns 
 */
export function getVehicleList(params) {
    return axios.get('/api/assets/vehicles/', { params });
}

/**
 * 获取车辆详情
 * @param {*} id 
 * @returns 
 */
export function getVehicleDetail(id) {
    return axios.get(`/api/assets/vehicles/${id}/`);
}

/**
 * 添加车辆
 * @param {*} data 
 * @returns 
 */
export function addVehicle(data) {
    return axios.post('/api/assets/vehicles/', data);
}

/**
 * 更新车辆信息
 * @param {*} id 
 * @param {*} data 
 * @returns 
 */
export function updateVehicle(id, data) {
    return axios.put(`/api/assets/vehicles/${id}/`, data);
}

/**
 * 删除车辆
 * @param {*} id 
 * @returns 
 */
export function deleteVehicle(id) {
    return axios.delete(`/api/assets/vehicles/${id}/`);
} 